Repository navigation
feat(remote-providers): DM-5782: add remote provider endpoints to the client - #90
AaronBarnes07 wants to merge 5 commits into
Conversation
… and export ParameterValue
…paths into constants
| response = self.make_request( | ||
| "POST", | ||
| f"/api/remote-providers/{remote_provider_id}/test/", | ||
| data={"value": value, "params": dict(params or {})}, | ||
| ) |
There was a problem hiding this comment.
On a non-2xx response, make_request passes data to _raise_for_status, which logs Request data was: ... at ERROR. _redact_sensitive hides only keys that contain password, secret, token, key or credential, so value and params are logged in clear. The docstring says the value is not saved or logged, and a caller can pass a real value here.
Call make_request(..., require_status_check=False), then self._raise_for_status(response) with no request_data, as _delete_if_exists does.
Add a test that a 400 from the test endpoint leaves the value and the params out of the log.
There was a problem hiding this comment.
Changed it to require_status_check=False then _raise_for_status(response) with no request data, and added a test that a 400 from the test endpoint keeps the value and params out of the log.
Summary
Adds remote providers to the client.
A remote provider is a service, hosted by the customer, that the
remote_httpmask sends values to over HTTP.The client can now create, list, get, update, delete and test them, following the pattern of the other admin entities.
What changed
Model (
datamasque/client/models/remote_provider.py)RemoteProviderwith its options as enums:CertificateVerification,RemoteProviderAuthType,TokenBodyFormat,RemoteProviderMethod.RemoteProviderParameter,RemoteProviderTestResult, theRemoteProviderIdtype andParameterValuefor test parameters.certificate_fileaccepts aFileIdor an uploadedCertificateFile, the same way run and discovery models accept a connection object or its ID.Noneand writesNoneback as a blank string.id,has_secret,created_dateandmodified_dateare read-only and are never sent.Client (
datamasque/client/remote_providers.py, mixed intoDataMasqueClient)list_remote_providers,get_remote_provider,get_remote_provider_by_namecreate_remote_provider,update_remote_provider,create_or_update_remote_providerdelete_remote_provider_by_id_if_exists,delete_remote_provider_by_name_if_existstest_remote_provider(id, value, params): sends one value and returns the provider's output or the error.Docs and history: both new modules are in the API reference, and
HISTORY.rsthas a 1.7.0 entry.Decisions for the reviewer
has_secretsays whether one is saved.secretis left out of the request body when it isNone, so an update without a secret keeps the saved one.It is also left out of the model's
repr, so it does not show up in logs or tracebacks.none.The client does not check this itself; the server's 400 comes back as
DataMasqueApiError, and the docstrings say so.get_remote_provider_by_namefilters the full list.test_remote_providertakes any mapping of parameters, so callers can pass aTypedDictor a read-only mapping.These endpoints need a DataMasque server version that has remote providers.
How it was tested
On the branch head (
0219daa):tests/test_remote_providers.py: 20 new tests against mocked HTTP, covering each call, the defaults, the secret kept out ofrepr, a create that sends the secret, an update without a secret that leaves it out of the body, an update that sends a new one, the blank token body format, a server field error raisingDataMasqueApiError, a refused create that does not log the secret, the delete no-op paths, and a test call returning both an output and an error.make test: 837 passed.make lint(ruff check, ruff format check, mypy): clean.